package com.cf.zookeeper.service;

import org.I0Itec.zkclient.IZkChildListener;
import org.I0Itec.zkclient.IZkDataListener;

import java.util.List;
import java.util.Map;

public interface ZkManager {

    ZkManagerImpl connect(String host, int timeout);

    List<String> getChildren(String path);

    String getData(String path);

    Map<String, String> getNodeMeta(String nodePath);

    List<Map<String, String>> getACLs(String nodePath);

    boolean createNode(String path, String nodeName, String data, int type);

    boolean createPersistentNode(String path, String nodeName, String data, boolean increase);

    boolean createTemporaryNode(String path, String nodeName, String data, boolean increase);

    boolean deleteNode(String nodePath);

    boolean setData(String nodePath, String data);

    void watchData(String path, IZkDataListener dataListener);

    void watchChild(String path, IZkChildListener childListener);

    enum Meta {
        czxid, mzxid, ctime, mtime, version, cversion, aversion, ephemeralOwner, dataLength, numChildren, pzxid
    }

    enum Acl {
        scheme, id, perms
    }
}
